package labs.fourth;

import labs.utilities.DefaultValue;

public class Token extends DefaultValue {
	private int type;
	private int lineNumber;
	private int charNumber;
	private String value;
	private boolean isError;

	public Token(String value, int lineNumber, int charNumber,
			TokenType... types) {
		this(value, lineNumber, charNumber, TokenType.getValue(types));
	}

	public Token(String value, int lineNumber, int charNumber, boolean isError,
			TokenType... types) {
		this(value, lineNumber, charNumber, TokenType.getValue(types), isError);
	}

	public Token(String value, int lineNumber, int charNumber, int type,
			boolean isError) {
		this.value = value;
		this.lineNumber = lineNumber;
		this.charNumber = charNumber;
		this.type = type;
		this.isError = isError;
	}

	public Token(String value, int lineNumber, int charNumber, int type) {
		this(value, lineNumber, charNumber, type, false);
	}

	/**
	 * @return the lineNumber
	 */
	public int getLineNumber() {
		return lineNumber;
	}

	/**
	 * @return the charNumber
	 */
	public int getCharNumber() {
		return charNumber;
	}

	/**
	 * @return the value
	 */
	public String getValue() {
		return value;
	}

	public void setError(boolean isError) {
		this.isError = isError;
	}

	public boolean isError() {
		return this.isError;
	}

	public boolean isIntegerLiteral() {
		return TokenType.isOfType(type, TokenType.INTEGER_LITERAL);
	}

	public boolean isAssignmentOperator() {
		return TokenType.isOfType(type, TokenType.ASSIGNMENT_OPERATOR);
	}

	public boolean isBasicType() {
		return TokenType.isOfType(type, TokenType.BASIC_TYPE);
	}

	public boolean isBooleanLiteral() {
		return TokenType.isOfType(type, TokenType.BOOLEAN_LITERAL);
	}

	public boolean isCharacterLiteral() {
		return TokenType.isOfType(type, TokenType.CHARACTER_LITERAL);
	}

	public boolean isFinalModifier() {
		return TokenType.isOfType(type, TokenType.FINAL_MODIFIER);
	}

	public boolean isFloatingPointLiteral() {
		return TokenType.isOfType(type, TokenType.FLOATING_POINT_LITERAL);
	}

	public boolean isIdentifier() {
		return TokenType.isOfType(type, TokenType.IDENTIFIER);
	}

	public boolean isInfixOperator() {
		return TokenType.isOfType(type, TokenType.INFIX_OPERATOR);
	}

	public boolean isModifier() {
		return TokenType.isOfType(type, TokenType.MODIFIER);
	}

	public boolean isNullLiteral() {
		return TokenType.isOfType(type, TokenType.NULL_LITERAL);
	}

	public boolean isPostfixOperator() {
		return TokenType.isOfType(type, TokenType.POSTFIX_OPERATOR);
	}

	public boolean isPrefixOperator() {
		return TokenType.isOfType(type, TokenType.PREFIX_OPERATOR);
	}

	public boolean isStringLiteral() {
		return TokenType.isOfType(type, TokenType.STRING_LITERAL);
	}
	
	@Override
	public String toString() {
		// TODO Auto-generated method stub
		return value;
	}
}
